﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RIMS.Lib.DataAccess.Implementations;
using RIMS.Lib.DataAccess.Interfaces;
using RIMS.Lib.Models;

namespace RIMS.Lib.Manager
{
    public class EmployeeManager
    {
        private readonly IEmployee _employeeDaolinq;

        public EmployeeManager()
        {
            _employeeDaolinq = new EmployeeDAOLinq();
        }

        public IList<Employee> GetAll()
        {
            return _employeeDaolinq.All();
        }

        public Employee Save(Employee employee)
        {
            employee.OID = Guid.NewGuid();
            if(_employeeDaolinq.Add(employee))
            {
                return employee;
            }
            return null;
        }

        public Employee GetEmployee(Guid OID)
        {
            return _employeeDaolinq.PickByOID(OID);
        }

        public Employee Update(Employee employee)
        {
            
            if (_employeeDaolinq.Edit((employee)))
            {
                return employee;
            }
            return null;
        }

        public bool Delete(Employee employee)
        {
            
            return _employeeDaolinq.Delete(employee);
        }

        public IList<Employee> Paging(int pageNo, int pageSize)
        {
            try
            {
                return _employeeDaolinq.Paging(pageNo, pageSize);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

    }
}
